<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>

<%
	String path = request.getContextPath();
	/* String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/"; 
	因为微信使用的是80端口 再JSSDK中签名验证不要端口号
	
	*/
	
%>
<!DOCTYPE html>
<!-- saved from url=(0072)http://www.juweinong.cn/app/index.php?i=3&c=entry&do=index&m=tiger_taoke -->
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>抢券购-省多多</title>

<meta name="viewport"
	content="width=device-width, initial-scale=1.0, maximum-scale=1.0,user-scalable=yes">
<script src="${ctx_tbk}js/jquery-1.7.2.min.js"></script>

<link href="${ctx_tbk}css/index.css" rel="stylesheet" type="text/css">

<script type="text/javascript" src="${ctx_tbk}js/jweixin-1.0.0.js"></script>
<!-- 微信自定义接口 -->
<script>
        var appid = "";
        var timestamp = "";
        var nonceStr = "";
        var signature = "";
        wx.config({
            debug: false,
            appId: appid,
            timestamp: timestamp,
            nonceStr: nonceStr,
            signature: signature,
            jsApiList: [
                "onMenuShareAppMessage",
                "onMenuShareTimeline",
                "chooseImage",
                "uploadImage",
                "downloadImage"
            ]
        });

	wx.ready(function(){
		wx.onMenuShareAppMessage({
			title: "天猫淘宝内部优惠券",
			desc: "阿里旗下平台合作伙伴，内部优惠券发布！",
			link: window.location.href ,
			imgUrl: ""
		}); 
		wx.onMenuShareTimeline({
			title: "天猫淘宝内部优惠券",
			desc: "阿里旗下平台合作伙伴，内部优惠券发布！",
			link: window.location.href ,
			imgUrl: ""
		});
	});
</script>
<!-- 微信自定义接口 -->
</head>
<body>


	<div style="max-width: 600px; margin: 0 auto; position: relative;">
		<div class="yhq_ssk" style="position: fixed; z-index: 10001">
			<div class="ssk_qb">
				<a href="/"> <img src="${ctx_tbk}img/ssk_fl.png" width="20"
					height="30" align="absmiddle">
				</a>
			</div>
			<div class="ssk" style="position: fixed; left: 10%;">
				<form id="search-form" action="/" method="get">
					<input type="hidden" name="i" value="3"> <input
						type="hidden" name="c" value="entry"> <input type="hidden"
						name="m" value="tiger_taoke"> <input type="hidden"
						name="do" value="index">
					<div class="ssk_fl">
						<style>
.seek_btn {
	position: absolute;
	width: 40px;
	height: 30px;
	right: 0px;
	top: 0px;
	-webkit-box-sizing: border-box;
	border: 1px;
	border-radius: 3px;
	cursor: pointer;
	background-color: #FFF;
}
</style>
						<input type="text" name="key" autocomplete="off" value=""
							placeholder="">
						<button type="submit" id="key" class="seek_btn" value="搜本站">
							<!-- 
							onclick="document.getElementById(&#39;key&#39;).value=encodeURI(document.getElementById(&#39;key&#39;).value);getId(&#39;search&#39;).submit()"
							 -->

							<img src="${ctx_tbk}img/ss_fd.png">
						</button>

					</div>
				</form>
			</div>
			<div class="ssk_fx">
				<a href="javascript:showShareFC();"> <img
					src="${ctx_tbk}img/ssk_fr.png" width="20" height="30"
					align="absmiddle"></a>
			</div>
		</div>
		<div class="yhq_topsm">
			<ul>
				<li class="yhq_topsm_fl">
					<div>
						<img src="${ctx_tbk}img/nz.png" width="16" height="14"
							align="absmiddle">&nbsp;内部优惠券，可与淘宝其他活动同时使用，数量有限！<br>
					</div>
				</li>
				<li class="yhq_topsm_fr"></li>
			</ul>
		</div>



		<div class="sp_con" style="margin-top: 15px;">
			<div class="cjf_con">
				<ul>
					<c:forEach items="${catlist}" var="s" varStatus="status">
						<li
						
						onclick=
<c:choose>
   <c:when test="${s.type != 'sys'}">  
"javascript:get_list(1,'${s.name}')"     
   </c:when>
   <c:otherwise> 
"javascript:window.location.href=&#39;/?catid=${s.id}&#39;"
   </c:otherwise>
</c:choose> class="handon">
							<div class="cjf_ev">
								<p
									<c:if test="${s.id== catid}">class="active" </c:if>>
									<c:out value="${s.name}"></c:out>
								</p>
							</div>
						</li>
					</c:forEach>



				</ul>
				<div class="clear"></div>
			</div>
		</div>

		<!----->
		<link href="${ctx_tbk}css/style.css" rel="stylesheet">
		<link href="${ctx_tbk}css/swipper.css" rel="stylesheet">

		<div id="containter index_goods">
			<div class="contain-product relative" style="border-top: 0">
				<div class="index_list_title">
					<span class="intro_title"><i>今日专享</i> <em>疯狂抢购</em></span>
					<!--span class="index_list_eachall"><a href="/Commodity/ListByCustomCategory?category=1">全部</a></span-->
				</div>
				<div
					class="contain--product-list swiper2 swiper-container-horizontal swiper-container-free-mode"
					style="width: 100%;">
					<ul class="swiper-wrapper" style="transform: translate3d(-819.4px, 0px, 0px); transition-duration: 0ms;">
						
<c:forEach items="${promotions}" var="p" varStatus="status">

						<li class="relative swiper-slide">
							<div class="contain-prolist-in">
								<a
									href="/item?id=${p.id}"
									class="ImgOut">
									<div class="allpreContainer">
										<img style="height: 146px; width: 146px;" src="${p.itempicurl}_200x200.jpg">
									</div>
								</a>
								<div class="contain-prolist-text">
									<h1>
										<a
											href="/item?id=${p.id}">${p.itemtitle}</a>
									</h1>
									<h2>																		
										<span>￥<fmt:formatNumber type="number" value="${p.itemprice-p.couponmoney}" maxFractionDigits="0" /> </span> <font>￥<fmt:formatNumber type="number" value="${p.itemprice}" maxFractionDigits="0" /> </font>
									</h2>
								</div>
								<a href="javascript:;" class="new-coupon"
									data-img="${p.itempicurl}"
									data-id="${p.id}"><span>领劵</span><span>立减${p.couponmoney}元</span></a>
							</div>
						</li>

</c:forEach>


						
					</ul>
				</div>
			</div>
		</div>
		<!----->



		<section class="goods" id="pageCon" style="padding-bottom: 60px;">

			<div id="list_box" class="list_box">



			</div>
			<div id="list_more" class="loading"
				style="margin-top: 10px; text-align: center">
				<span onclick="get_list(2);">点击查看更多</span>
			</div>
		</section>
	</div>

	<%@ include file="footer.jsp"%>



	<link rel="stylesheet" href="${ctx_tbk}css/dropload.css">
	<script src="${ctx_tbk}js/dropload.min.js"></script>
	<script type="text/javascript">

var limit = 1;
var lastpage = false;
var keywords = "${keywords}";
var catid = "${catid}";
function get_list(ty,kw){    
    if(ty==1){
	   $("#pageCon .list_box").html('');
	}else{
	   $("#list_more").html('<div class="loading"><span > 卖命加载中...</span></div>');	   
	}    
    if  ( lastpage == true ) return;
	
	$.ajax({
	    type : "post",
	    url : "list?page="+ty,
	    data : {
	    	catid:catid,	   
	    	limit:limit,
	    	keywords:kw
	    },
        dataType : "json",		
	    success : function(data) {	    	
	    	console.log("data.status:"+data.status);
	    	if(data.status==1){
	    		 limit++;
	    		 lastpage = data.content.lastPage;
						var list = data.content.list;
						var ctx_tbk = data.ctx_tbk;
						console.log("data.content.list:"+list.length);
						console.log("data.ctx_tbk:"+ctx_tbk);
						var content = '';
						for(var i=0; i<list.length; i++){
							p = list[i];
							console.log("data.content.list["+i+"].itempicurl:"+p.itempicurl);
					        content+='<a href=/item?id='+p.id+'><div class="yhj" onclick="javascript:window.location.href=/item?id='+p.id+'">';
					        content+='<div class="yhj_l">';
					        content+='<img src="'+p.itempicurl+'_150x150.jpg" width="85" height="85">';
					        content+='	</div>';
					        content+='	<div class="yhj_m">';
					        content += '		<div class="title">';
					        content += '			<span><img src="'+ctx_tbk+'img/tm.png" width="40"';
					        content += '				height="40"></span>&nbsp;<font class="title2">'+p.title+'}</font>';
					        content += '		</div>';
					        content += '		<div class="mes">';
					        content += '			现 价 <span class="gr">￥' + p.price.toFixed(0) +'</span><br>优惠券 <span';
					        content += '				class="red">'+p.couponmoney +' </span>';
					        content += '		</div>';
					        content += '	</div>';
					        content += '	<div class="yhq_img">';
					        content += '		<img src="'+ctx_tbk+'img/yhj_m.jpg" width="12" height="95">';
					        content += '	</div>';
					        content += '	<div class="yhj_r">';
					        content += '		￥'+(p.price-p.couponmoney).toFixed(0)+'<br> <span>券后价</span>';
					        content += '	</div>';
					        content += '</div></a>';
						}
                        $("#pageCon .list_box").append(content);
						var aa = $(".goods-list li").innerWidth();
                        $(".goods-list li img").css('height',aa);
						if(list.length>1){
							$("#list_more").html('<span onclick="get_list('+limit+');">点击查看更多</span>');
						}else{
							$("#list_more").html('<span></span>');
							$("#list_more").fadeOut(500);
						}
	    }else if( data.status =2){	    	
	    		 limit++;
	    		 lastpage = data.content.lastPage;
						var list = data.content.list;
						var ctx_tbk = data.ctx_tbk;
						console.log("data.content.list:"+list.length);
						console.log("data.ctx_tbk:"+ctx_tbk);
						var content = '';
						for(var i=0; i<list.length; i++){
							p = list[i];
							console.log("data.content.list["+i+"].title:"+p.itemtitle);
					        content+='<a href=/item?id='+p.id+'><div class="yhj" onclick="javascript:window.location.href=/item?id='+p.id+'">';
					        content+='<div class="yhj_l">';
					        content+='<img src="'+p.itempicurl+'_150x150.jpg" width="85" height="85">';
					        content+='	</div>';
					        content+='	<div class="yhj_m">';
					        content += '		<div class="title">';
					        content += '			<span><img src="'+ctx_tbk+'img/tm.png" width="40"';
					        content += '				height="40"></span>&nbsp;<font class="title2">'+p.itemtitle+'}</font>';
					        content += '		</div>';
					        content += '		<div class="mes">';
					        content += '			现 价 <span class="gr">￥' + p.itemprice.toFixed(0) +'</span><br>优惠券 <span';
					        content += '				class="red">'+p.couponmoney +' </span>';
					        content += '		</div>';
					        content += '	</div>';
					        content += '	<div class="yhq_img">';
					        content += '		<img src="'+ctx_tbk+'img/yhj_m.jpg" width="12" height="95">';
					        content += '	</div>';
					        content += '	<div class="yhj_r">';
					        content += '		￥'+(p.itemprice-p.couponmoney).toFixed(0)+'<br> <span>券后价</span>';
					        content += '	</div>';
					        content += '</div></a>';
						}
                       $("#pageCon .list_box").append(content);
						var aa = $(".goods-list li").innerWidth();
                       $(".goods-list li img").css('height',aa);
						if(data.content.lastPage != true){
							$("#list_more").html('<span onclick="get_list('+limit+');">点击查看更多</span>');
						}else{
							$("#list_more").html('<span></span>');
							$("#list_more").fadeOut(500);
						}			  
		    }else if(data.status==3){
	    		$("#list_more").html('<span>没有更多记录！</span>');
				//dialog("没有更多记录！");
				$("#list_more").fadeOut(500);
	    	}else{
			    $("#list_more").html('<span>没有更多记录！</span>');
				//dialog("没有更多记录！！");
				$("#list_more").fadeOut(500);
			}    	
	    },
	    error : function(xhr, type) {
	    	
	    }
	});
	    

}
get_list(1,keywords);


//==============自动加载=============
//获取滚动条当前的位置 
function getScrollTop() { 
var scrollTop = 0; 
if (document.documentElement && document.documentElement.scrollTop) { 
scrollTop = document.documentElement.scrollTop; 
} 
else if (document.body) { 
scrollTop = document.body.scrollTop; 
} 
return scrollTop; 
} 

//获取当前可是范围的高度 
function getClientHeight() { 
var clientHeight = 0; 
if (document.body.clientHeight && document.documentElement.clientHeight) { 
clientHeight = Math.min(document.body.clientHeight, document.documentElement.clientHeight); 
} 
else { 
clientHeight = Math.max(document.body.clientHeight, document.documentElement.clientHeight); 
} 
return clientHeight; 
} 

//获取文档完整的高度 
function getScrollHeight() { 
return Math.max(document.body.scrollHeight, document.documentElement.scrollHeight); 
} 


$(window).scroll(function () { 
if (getScrollTop() + getClientHeight() == getScrollHeight()) { 
//alert("到达底部"); 
get_list(limit);
} 
});

//==============自动加载=============  


</script>

	<div class="fc_share">
		<img src="${ctx_tbk}img/fx_fc.png" style="width: 80%">
	</div>
	<div class="fc_share_bg"></div>

	<script type="text/javascript">
        
        $(function($){
            $('.fc_share_bg').click(function(){
                $('.fc_share').hide();
                $('.fc_share_bg').hide();
            });
            $('.fc_share').click(function(){
                $('.fc_share').hide();
                $('.fc_share_bg').hide();
            });
        });
        
        function showShareFC(){
            
            $('.fc_share').show();
            $('.fc_share_bg').show();
            
        }
        
    </script>

	<script src="${ctx_tbk}js/tool.js"></script>
	<script src="${ctx_tbk}js/asynloading.js"></script>
	<script src="${ctx_tbk}js/idangerous.swiper.min.js"></script>
	<script src="${ctx_tbk}js/common_phone.js"></script>

	<script>        
      var swiper = new Swiper('.swiper-container', {
                pagination: '.swiper-pagination',
                paginationClickable: true,
                loop: true,
                effect:'flip',
                autoplay:5000,
            });
      var swiper2 = new Swiper('.swiper2', {
                slidesPerView: 'auto',
                paginationClickable: true,
                freeMode: true,
                autoplay:3000,
                pagination: '.swiper-pagination',
                
      });


//弹出领券
    $(document).delegate(".new-coupon,.goodsget", "click", function () {        
        var $this = $(this);
        //alert($this.attr("data-img"));
        var id = $this.data("id");
        $.ajax({
            type: "post",
            url: "./index.php?i=3&c=entry&do=GetCoupon&m=tiger_taoke",
            dataType: "json",
            data: { id: id },
            success: function (data) {
                if (data.msg == "申请失败") {
                    popTao($this.attr("data-img"), "淘口令", "您暂无权限领取该优惠券，请先升级会员");
                    $(".taokaobox").html("<div class='popwcc'><a href='javascript:;' onclick='location.href=\"/Customer/Upgrade\"' class='popwcomfirm'>去升级</a></div>");
                    //location.href = "/Customer/Upgrade";
                }
                else {
                    popTao($this.attr("data-img"), "淘口令", data.url);
                }
                selection()
            }
        });
    })
    </script>


</body>
</html>
